import { nextTick, reactive, Ref, ref, watch } from 'vue'

const useTable = () => {
  const tableData = reactive({
    dialogVisible: false,
    currentId: '',
    searchForm: {}
  })
  const msTable = ref<any>(null)
  const searchTable = () => nextTick(() => msTable.value.handleGetData(undefined, undefined, tableData.searchForm))

  watch(() => tableData.dialogVisible, (val) => !val && searchTable())

  return {
    searchTable,
    msTable,
    tableData
  }
}

export default useTable
